# Contributor: Díaz Urbaneja Diego <sodomon2@gmail.com>
# Maintainer: Díaz Urbaneja Diego <sodomon2@gmail.com>
pkgname=paho-mqtt-c
pkgver=1.3.9
pkgrel=0
pkgdesc="Fully fledged MQTT client written in ANSI standard C"
url="https://www.eclipse.org/paho/clients/c/"
arch="all"
license="EPL-1.0"
makedepends="cmake openssl-dev"
options="!check" # make check not implemented
subpackages="$pkgname-dev $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/eclipse/paho.mqtt.c/archive/v$pkgver.tar.gz"
builddir="$srcdir/paho.mqtt.c-$pkgver"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DPAHO_WITH_SSL=TRUE \
		$CMAKE_CROSSOPTS .
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	# install man pages
	for dir in MQTTAsync MQTTClient; do
		install -Dm644 "docs/$dir/man/man3/"*.3 \
			-t "$pkgdir"/usr/share/man/man3/
	done
}

sha512sums="
2a2ad34df508d8d97ef5382310ba28bb5280843bec337770a2e20442405dde3283473a6038b23fbc1a79bd60d1dfb72d6b508ae4338e95d88b370c0e5625dae5  paho-mqtt-c-1.3.9.tar.gz
"
